package com.iwhalecloud.bss.kite.cucc.web.service.accept.handler.module;

import com.google.common.collect.Lists;
import com.iwhalecloud.bss.kite.cart.common.util.KiteCartStringUtils;
import com.iwhalecloud.bss.kite.client.api.scene.operate.IOperateSceneCommonService;
import com.iwhalecloud.bss.kite.client.api.scene.query.IQuerySceneAccessProdInstService;
import com.iwhalecloud.bss.kite.client.dto.inst.ProdInstDTO;
import com.iwhalecloud.bss.kite.client.dto.spec.OfferDetailDTO;
import com.iwhalecloud.bss.kite.client.dto.spec.OfferGrpMemberDTO;
import com.iwhalecloud.bss.kite.client.vo.scene.*;
import com.iwhalecloud.bss.kite.common.constant.KeyConsts;
import com.iwhalecloud.bss.kite.common.constant.KeyConsts2;
import com.iwhalecloud.bss.kite.common.util.KiteBeanUtils;
import com.iwhalecloud.bss.kite.common.util.KiteListUtils;
import com.iwhalecloud.bss.kite.common.util.KiteMapUtils;
import com.iwhalecloud.bss.kite.common.util.KiteStringUtils;
import com.iwhalecloud.bss.kite.cucc.client.dto.goods.GoodsMemberDTO;
import com.iwhalecloud.bss.kite.cucc.client.dto.goods.MemberGoodDTO;
import com.iwhalecloud.bss.kite.cucc.client.vo.scene.GiftOfferInstModuleVO;
import com.iwhalecloud.bss.kite.cucc.client.vo.scene.SceneNewOfferSeneVO;
import com.iwhalecloud.bss.kite.cucc.common.constant.CuccServiceOfferConsts;
import com.iwhalecloud.bss.kite.cucc.common.constant.LocalKeyConsts;
import com.iwhalecloud.bss.kite.cucc.dataservice.cache.CuccOfferGrpMemberCache;
import com.iwhalecloud.bss.kite.cucc.dataservice.cache.CuccOfferMemberCache;
import com.iwhalecloud.bss.kite.cucc.service.goods.GoodsHelper;
import com.iwhalecloud.bss.kite.cucc.spec.impl.transfer.GoodsInfoTransfer;
import com.iwhalecloud.bss.kite.dataservice.cache.DcPublicCache;
import com.iwhalecloud.bss.kite.dataservice.cache.OfferCache;
import com.iwhalecloud.bss.kite.dataservice.cache.OfferOrderTimesRuleCache;
import com.iwhalecloud.bss.kite.dataservice.cache.ProdAttrCache;
import com.iwhalecloud.bss.kite.dataservice.entity.DcPublic;
import com.iwhalecloud.bss.kite.dataservice.entity.OfferOrderTimesRule;
import com.iwhalecloud.bss.kite.dataservice.entity.spec.ProdAttr;
import com.iwhalecloud.bss.kite.manager.api.IQuerySceneInstService;
import com.iwhalecloud.bss.kite.manager.dto.KiteInstRelDTO;
import com.iwhalecloud.bss.kite.manager.enums.ActionType;
import com.iwhalecloud.bss.kite.manager.enums.InstType;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteOfferInst;
import com.iwhalecloud.bss.kite.manager.inst.KiteProdInst;
import com.iwhalecloud.bss.kite.web.service.accept.bo.AcceptContext;
import com.iwhalecloud.bss.kite.web.service.accept.bo.SceneModule;
import com.ztesoft.bss.common.util.ContextUtil;
import com.ztesoft.bss.common.util.SpringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;
import java.util.stream.Collectors;

/**
 * 附加产品
 * @author zou.qinghua
 *
 */
@Service
public class OptionalAdditionalProductModuleHandler extends LocalAbstractProductModuleHandler {

    @Autowired
    private IQuerySceneInstService querySceneInstService;

    @Autowired
    private IQuerySceneAccessProdInstService querySceneProdInstService;

    @Override
    public List<? extends ModuleVO> execute(AcceptContext context, SceneModule sceneModule) {
        return  executePreview(context,sceneModule,false);
    }
    //添加预览标志
    public List<? extends ModuleVO> executePreview(AcceptContext context, SceneModule sceneModule,Boolean previewFlag) {
        String sceneInstId = context.getAcceptRequest().getSceneInstId();
        List<KiteOfferInst> mainOfferInsts = querySceneInstService.listMainOfferInsts(sceneInstId);
        if (KiteListUtils.isEmpty(mainOfferInsts)) {
            return Lists.newArrayList();
        }
        mainOfferInsts.addAll(querySceneInstService.listGiftOfferInsts(sceneInstId));
        List<AdditionalProductModuleVO> addiProds = Lists.newArrayList();
        mainOfferInsts.forEach(offerInst -> {
            dealOfferMembers(context, sceneModule, offerInst.getOfferInstId(), offerInst.getOfferId(),previewFlag);
        });
        return addiProds;
    }
    private void dealOfferMembers(AcceptContext context, SceneModule sceneModule, String offerInstId, String offerId,Boolean previewFlag) {
        String cateId = OfferCache.get(offerId).getCateId();
        if (GoodsInfoTransfer.isAddRoleOffer(offerId, cateId)) {
            return;
        }
        String provinceCode = ContextUtil.getLoginInfo().getUserInfo().getPostProvinceNbr();
        String sceneInstId = context.getAcceptRequest().getSceneInstId();
        String serviceOfferId = context.getAcceptRequest().getServiceOfferId();
        String taskCode = querySceneInstService.getExtParameterValue(sceneInstId, "taskCode");
        Map<String,Map> oppoDetail = querySceneInstService.getExtParameterValue(sceneInstId,"OPPO_DETAIL");
        //List<OfferRelInfo> offerMembers = OfferRelCache.listOfferMemberRels(offerId);
        AdditionalProductHeadModuleVO additionalProduct = new AdditionalProductHeadModuleVO();
        List<GoodsMemberDTO> offerMembers = CuccOfferMemberCache.get(offerId, ContextUtil.getLoginInfo().getUserInfo().getPostProvinceNbr());
        //List<GoodsMemberDTO> offerMembers = goodsService.queryGoodsMember(offerId).getResultObject();

        List<ModuleVO> addProdVOs = new ArrayList<ModuleVO>();
        Map<String, List<ModuleVO>> modulesMap = new HashMap<>();
        for (GoodsMemberDTO member : offerMembers) {
            CommonAttrModuleVO operModule = new CommonAttrModuleVO();
            List<CommonAttrVO> operAttrList = Lists.newArrayList();
            KiteBeanUtils.copyProperties(sceneModule.getKiteModule(), operModule);
            KiteBeanUtils.copyProperties(sceneModule.getKiteModule(), additionalProduct);
            String operModuleType = null;
            String offerGrpId = null;
            operModule.setModuleType("CheckboxModule");
            int orderId = 0;
            String statusCd = member.getStatusCd();
            List<MemberGoodDTO> memberGoods = member.getMemberGoods();
            if(KiteMapUtils.isNotEmpty(oppoDetail)){
                Map<String,Map> oppoMebs = KiteMapUtils.getMap(oppoDetail,"OPPO_MEMBERS");
                if(KiteMapUtils.isNotEmpty(oppoMebs)){
                    memberGoods = memberGoods.stream().filter(it->oppoMebs.containsKey(it.getGoodsSku())).collect(Collectors.toList());
                }else{
                    memberGoods = new ArrayList<>();
                }
            }
            //天津订购不展示集群通信附加产品、手机看店附加产品
            if (LocalKeyConsts.PROVINCE_TIANJIN.equals(provinceCode) && KiteStringUtils.isEqual("1", serviceOfferId)) {
                memberGoods.removeIf(memberGoodDTO -> KiteStringUtils.equalsAny(memberGoodDTO.getGoodsSku(), LocalKeyConsts.J200000000010381,LocalKeyConsts.S200000000010379,"200000000007799","200000000007797"));
            }
            String max = member.getMax();
            String min = member.getMin();
            // 下面这层是正真的附加商品
            for (MemberGoodDTO goods : memberGoods) {
                orderId++;
                CommonAttrVO operAttr = new CommonAttrVO();
                operAttr.setAttrId(goods.getGoodsSku());
                operAttr.setCname(goods.getGoodsName());
                operAttr.setFieldName(goods.getGoodsSku());
                if (KiteStringUtils.isEqual(max, min) && KiteStringUtils.isEqual(max, String.valueOf(memberGoods.size()))) {
                    operAttr.setIsEdit("F");
                }
                else {
                    operAttr.setIsEdit("T");
                }
                operAttr.setIsNull("T");

                List<ProdRoleModuleVO> prodRole = new ArrayList<ProdRoleModuleVO>();
                AdditionalProductModuleVO addiProdVO = new AdditionalProductModuleVO();
                addiProdVO.setModuleId(goods.getGoodsSku());
                addiProdVO.setModuleName(goods.getGoodsName());
                addiProdVO.setOfferId(goods.getGoodsSku());
                addiProdVO.setOfferName(goods.getGoodsName());
                addiProdVO.setModuleType(this.getModuleType(goods.getGoodsSku()));
                addiProdVO.setOrderId(KiteStringUtils.valueOf(orderId));
                addiProdVO.setIsShow("T");
                addiProdVO.setIsEdit("T");
                // 雁飞格物DMP平台-私有化商品，业务变更不允许修改附加商品
                if(CuccServiceOfferConsts.SERVICE_OFFER_PRODUCT_CHANGE.equals(serviceOfferId) && "50041564".equals(goods.getGoodsSku())){
                    addiProdVO.setIsEdit("F");
                }
                // 获取附加商品的明细
                List<OfferDetailDTO> offerDetails = KiteBeanUtils
                    .copyPropsForList(OfferCache.get(goods.getGoodsSku()).listAccessProdDetail(),
                        OfferDetailDTO.class);
                if (KiteListUtils.isEmpty(offerDetails)) {
                    continue;
                }
                String prodId = offerDetails.get(0).getObjId();
                String offerId_meb = offerDetails.get(0).getOfferId();
                // 追加配件时，非实物附加商品的checkBox不可编辑
                if (KiteStringUtils.isEqual("2020", serviceOfferId)) {
                    if (!GoodsHelper.isMaterialProduct(prodId)) {
                        operAttr.setIsEdit("F");
                    }
                }

                List<ProdInstDTO> prodInstList = querySceneProdInstService
                    .listEffProdInsts(context.getAcceptRequest().getSceneInstId(), context.getAcceptRequest().getCustId())
                    .getResultObject();
                prodInstList = prodInstList.stream()
                    .filter((prodInst) -> {
                        KiteOfferInst offerInst = querySceneInstService.listMainOfferInstsByProdInstId(context.getAcceptRequest().getCustId(), prodInst.getProdInstId()).stream().findFirst().orElse(null);
                        if (Objects.isNull(offerInst)) {
                            offerInst = querySceneInstService.getOnlyGiftOfferInstByProdInstId(context.getAcceptRequest().getCustId(), prodInst.getProdInstId());
                        }
                        if (Objects.nonNull(offerInst)) {
                            return (KeyConsts.PROD_FUNC_TYPE_101.equals(prodInst.getProdFuncType()) && !KiteStringUtils.isEqual(prodInst.getActionType(), ActionType.D.name()) && KiteStringUtils.isEqual(prodInst.getProdId(),prodId) && KiteStringUtils.equals(offerInst.getOfferId(),offerId_meb));
                        }
                        return false;
                    })
                    .collect(Collectors.toList());
                if (!KiteListUtils.isEmpty(prodInstList)) {
                    List<ProductModuleVO> prodVOs = getProdModuleVO(offerDetails, prodInstList, context);
                    divideProdAttr(prodVOs, context.getAcceptRequest().getSceneInstId(), context.getAcceptRequest().getCustId(), previewFlag);
                    prodVOs.forEach(prod -> {
                        List<ProdRoleModuleVO> prodRoles = prod.getProdRole();
                        if (KiteListUtils.isNotEmpty(prodRoles)) {
                            prodRoles.forEach(prodRoleModuleVO -> prodRoleModuleVO.getProdAttr().getProdAttrList().removeIf(attr -> KeyConsts.PROD_ATTR_SHOW_TYPE_E.equals(attr.getShowType())));
                            //  融合追加附加产品不可编辑, 物联网受理单补录不允许修改信息
                            if (CuccServiceOfferConsts.SERVICE_OFFER_ADD_TO.equals(serviceOfferId) || KiteStringUtils.equals(taskCode, "OrderAddRecordWLWXS")) {
                                prodRoles.forEach(prodRoleModuleVO -> prodRoleModuleVO.getProdAttr().getProdAttrList().forEach(attr -> attr.setIsEdit(KeyConsts.IFTRUE_F)));
                                addiProdVO.setIsEdit("F");
                            }
                            prodRole.addAll(prodRoles);
                        }
                    });
                    addiProdVO.setList(prodRole);

                    operAttr.setValue("T");

                    SpringUtil.getBean(IOperateSceneCommonService.class)
                        .setCommonAttrValue(context.getAcceptRequest().getSceneInstId(), goods.getGoodsSku(),
                            goods.getGoodsSku(), goods.getGoodsName());
                }else if(KiteStringUtils.equals(statusCd, KeyConsts2.PROD_STATUS_HIS_00C)){
                    continue;
                }
                if ("10004282".equals(addiProdVO.getOfferId())) {
                    IQuerySceneInstService querySceneInstService = SpringUtil.getBean(IQuerySceneInstService.class);
                    List<KiteProdInst> kiteProdInstList = querySceneInstService
                        .listProdInsts(context.getAcceptRequest().getSceneInstId());
                    if (KiteListUtils.isNotEmpty(kiteProdInstList)) {
                        for (KiteProdInst prodInst : kiteProdInstList) {
                            KiteAttr serviceLevelAttr = prodInst.getAttr("200003681");
                            if (serviceLevelAttr == null) {
                                continue;
                            }
                            //如果平台服务级别是高级平台，然后附加产品-可付费套包不能选择
                            if ("100006417".equals(serviceLevelAttr.getValue())) {
                                addiProdVO.setIsEdit("F");
                                operAttr.setIsEdit("F");
                            }
                        }
                    }
                }

                OfferGrpMemberDTO offerGrpMember = CuccOfferGrpMemberCache.get(offerId, addiProdVO.getOfferId());
                if (Objects.nonNull(offerGrpMember)) {
                    operModuleType = dealOperModuleType(prodRole,operModuleType, offerGrpMember.getGrpType(), prodId, operModule);
                    if (KiteStringUtils.isEmpty(offerGrpId)) {
                        offerGrpId = offerGrpMember.getOfferGrpId().toString();
                    }
                    List<ModuleVO> addMember = Optional
                        .ofNullable(modulesMap.get(offerGrpMember.getOfferGrpId().toString()))
                        .orElse(Lists.newArrayList());
                    addMember.add(addiProdVO);
                    modulesMap.put(offerGrpMember.getOfferGrpId().toString(), addMember);
                }
                else {
                    // 如果没有配置，则使用默认分组
                    offerGrpId = "-1";
                    List<ModuleVO> addMember = Optional.ofNullable(modulesMap.get(offerGrpId)).orElse(Lists.newArrayList());
                    addMember.add(addiProdVO);
                    modulesMap.put(offerGrpId, addMember);
                }

                operAttrList.add(operAttr);
                addProdVOs.add(addiProdVO);

            }

            operModule.setOfferGrpId(offerGrpId);
            operModule.setModuleType(operModuleType);
            List<ModuleVO> moduleVOList = Optional.ofNullable(modulesMap.get(operModule.getOfferGrpId()))
                .orElse(Lists.newArrayList());
            if (KiteListUtils.isNotEmpty(moduleVOList) && KiteStringUtils.equals(offerGrpId, "-1")) {
                // 如果是默认分组，则所有附加商品都在一个分组下，操作栏只需要一个
                ModuleVO moduleVO = moduleVOList.get(0);
                if (moduleVO instanceof CommonAttrModuleVO) {
                    operModule.setModuleName(null);
                    CommonAttrModuleVO commonAttrModuleVO = (CommonAttrModuleVO) moduleVO;
                    operAttrList.addAll(commonAttrModuleVO.getCommonAttrList());
                    moduleVOList.remove(0);
                }
            }
            else {
                operModule.setModuleName(member.getMemberName());
            }
            operModule.setCommonAttrList(operAttrList);
            moduleVOList.add(0, operModule);
        }

        additionalProduct.setModulesMap(modulesMap);

        List<KiteInstRelDTO> prodInstRels = this.querySceneInstService.listInstRelsByAInst(context.getAcceptRequest().getCustId(), InstType.MAIN_OFFER_INST, offerInstId, InstType.PROD_INST);
        prodInstRels.forEach(prodInstRel -> {
            if (KiteStringUtils.equals(KeyConsts.OFFER_TYPE_11, OfferCache.get(offerId).getOfferType())) {
                List<ProductModuleVO> products = ((SceneNewOfferSeneVO) context.getSceneVo()).getSceneProductModuleVO().getProduct()
                    .stream().filter(prodInst -> KiteStringUtils.isEqual(prodInst.getProdId(), prodInstRel.getzSpecId())).collect(Collectors.toList());
                if (!KiteListUtils.isEmpty(products)) {
                    products.get(0).setAddProdModule(additionalProduct);
                }
            }
        });
        if (KiteStringUtils.equals(KeyConsts.OFFER_TYPE_15, OfferCache.get(offerId).getOfferType())) {
            ((SceneNewOfferSeneVO) context.getSceneVo()).getSceneProductModuleVO().getGiftOfferInstModuleVO().setAddProdModule(additionalProduct);
        }
    }

    private String dealOperModuleType(List<ProdRoleModuleVO> prodRole,String operModuleType, String grpType, String prodId,
                                      CommonAttrModuleVO operModule) {
        if (KiteStringUtils.isNotEmpty(operModuleType)) {
            return operModuleType;
        }
        if (KiteStringUtils.equals(grpType, "2100")) {
            // 设置表头，ListCheckboxModule中同组的商品属性都是一致的，取一个商品的属性作为表头

            if(KiteListUtils.isNotEmpty(prodRole)&&KiteStringUtils.equals(prodRole.get(0).getProdId(),prodId)){
                List<ProdAttrVO> prodAttr = prodRole.get(0).getProdAttr().getProdAttrList();
                operModule.setTitleAttr(prodAttr);
            }
            if(KiteListUtils.isEmpty(operModule.getTitleAttr())){
                List<ProdAttr> prodAttrList = Optional.ofNullable(ProdAttrCache.get(prodId)).orElse(Lists.newArrayList());
                prodAttrList.removeIf(prodAttr -> !KiteCartStringUtils.equals(prodAttr.getShowType(), KeyConsts.PROD_ATTR_SHOW_TYPE_D));
                operModule.setTitleAttr(KiteBeanUtils.copyPropsForList(prodAttrList, ProdAttrVO.class));
            }
            return LocalKeyConsts.MODULE_TYPE_HANDLER_LIST_CHECKBOX;
        }
        return LocalKeyConsts.MODULE_TYPE_HANDLER_CHECKBOX;
    }

    private String getModuleType(String offerId) {
        List<DcPublic> dcPublics = DcPublicCache.get("20201112002");
        if (!KiteListUtils.isEmpty(dcPublics)) {
            dcPublics = dcPublics.stream().filter(dc -> !KiteStringUtils.isEmpty(dc.getCodea()) && dc.getCodea().contains(offerId)).collect(Collectors.toList());
            if (KiteListUtils.isNotEmpty(dcPublics)) {
                return dcPublics.get(0).getPcode();
            }
        }
        OfferOrderTimesRule offerOrderTimesRule = OfferOrderTimesRuleCache.get(offerId);
        if (Objects.nonNull(offerOrderTimesRule)) {
            String orderTimes = offerOrderTimesRule.getOrderTimes();
            if (KiteStringUtils.isNum(orderTimes) && Integer.parseInt(orderTimes) > 1) {
                return LocalKeyConsts.MODULE_TYPE_HANDLER_ATTR_TABLE;
            }
        }
        return LocalKeyConsts.MODULE_TYPE_HANDLER_FORM;
    }

    @Override
    public List<? extends ModuleVO> previewSceneVo(AcceptContext context, SceneModule sceneModule) {
        executePreview(context, sceneModule,true);
        List<ProductModuleVO> products = ((SceneNewOfferSeneVO) context.getSceneVo()).getSceneProductModuleVO().getProduct();

        if(KiteListUtils.isEmpty(products)){
            return new ArrayList<>();
        }

        GiftOfferInstModuleVO giftOfferInstModuleVO = ((SceneNewOfferSeneVO) context.getSceneVo()).getSceneProductModuleVO().getGiftOfferInstModuleVO();
        if (Objects.nonNull(giftOfferInstModuleVO) && Objects.nonNull(giftOfferInstModuleVO.getAddProdModule())) {
            giftOfferInstModuleVO.getAddProdModule().getModulesMap().forEach((offerGrpId, giftModuleList) -> {
                if (KiteListUtils.isEmpty(giftModuleList)) {
                    return;
                }
                giftModuleList.forEach(giftModule -> {
                    giftModule.setIsEdit("F");
                    if (giftModule instanceof AdditionalProductModuleVO) {
                        ((AdditionalProductModuleVO) giftModule).getList().forEach(role -> {
                            role.setIsEdit("F");
                            role.getProdAttr().getProdAttrList().forEach(attr -> {
                                if (KiteStringUtils.isEmpty(attr.getValue()) && KiteStringUtils.isEmpty(attr.getValueDesc())) {
                                    attr.getAttrValues().stream().forEach(value -> {
                                        if (KiteStringUtils.isEqual(value.getAttrValue(), attr.getDefaultValue())) {
                                            attr.setValue(value.getAttrValue());
                                            attr.setValueDesc(value.getAttrValueDesc());
                                        }
                                    });
                                }
                                if(KiteStringUtils.equals(attr.getPageUrl(),"AttrProdAttachment")){
                                    attr.setAttrValueTypeId("98F");
                                }else {
                                    attr.setAttrValueTypeId("TT");
                                }
                            });
                        });
                    }
                    else {
                        ((CommonAttrModuleVO) giftModule).getCommonAttrList().forEach(attr -> {
                            attr.setIsEdit("F");
                        });
                    }
                });
            });
        }

        products.forEach(prod -> {
            if(Objects.isNull(prod.getAddProdModule())|| KiteMapUtils.isEmpty(prod.getAddProdModule().getModulesMap())){
                return;
            }
            prod.getAddProdModule().getModulesMap().forEach((offerGrpId, moduleVOList) -> {
                if (KiteListUtils.isEmpty(moduleVOList)) {
                    return;
                }
                moduleVOList.forEach(module -> {
                    module.setIsEdit("F");
                    if (module instanceof AdditionalProductModuleVO) {
                        ((AdditionalProductModuleVO) module).getList().forEach(role -> {
                            role.setIsEdit("F");
                            role.getProdAttr().getProdAttrList().forEach(attr -> {
                                //如果 value和valueDesc没有值则从AttrValues找到转义值返回
                                if (KiteStringUtils.isEmpty(attr.getValue()) && KiteStringUtils.isEmpty(attr.getValueDesc())) {
                                    attr.getAttrValues().stream().forEach(value -> {
                                        if (KiteStringUtils.isEqual(value.getAttrValue(), attr.getDefaultValue())) {
                                            attr.setValue(value.getAttrValue());
                                            attr.setValueDesc(value.getAttrValueDesc());
                                        }
                                    });
                                }
                                if(KiteStringUtils.equals(attr.getPageUrl(),"AttrProdAttachment")){
                                    attr.setAttrValueTypeId("98F");
                                }else {
                                    attr.setAttrValueTypeId("TT");
                                }
                            });

                            role.getGroupProdAttr().forEach(groupProdAttr ->{
                                if (KiteListUtils.isNotEmpty(groupProdAttr.getButtonAttrList())) {
                                    // 将新增按钮置空
                                    groupProdAttr.setButtonAttrList(Lists.newArrayList());
                                }
                                if (KiteListUtils.isNotEmpty(groupProdAttr.getFormProdAttrList())) {
                                    groupProdAttr.getFormProdAttrList().forEach(prodAttr ->{
                                        //如果 value和valueDesc没有值则从AttrValues找到转义值返回
                                        if (KiteStringUtils.isEmpty(prodAttr.getValue()) && KiteStringUtils.isEmpty(prodAttr.getValueDesc())) {
                                            prodAttr.getAttrValues().stream().forEach(value -> {
                                                if (KiteStringUtils.isEqual(value.getAttrValue(), prodAttr.getDefaultValue())) {
                                                    prodAttr.setValue(value.getAttrValue());
                                                    prodAttr.setValueDesc(value.getAttrValueDesc());
                                                }
                                            });
                                        }
                                        if(KiteStringUtils.equals(prodAttr.getPageUrl(),"AttrProdAttachment")){
                                            prodAttr.setAttrValueTypeId("98F");
                                        }else {
                                            prodAttr.setAttrValueTypeId("TT");
                                        }
                                    });
                                }

                            });
                        });
                    }
                    else {
                        ((CommonAttrModuleVO) module).getCommonAttrList().forEach(attr -> {
                            attr.setIsEdit("F");
                        });
                    }
                });
            });

        });
        return products;
    }

}
